package net 
{
	import app.Application;
	import binary.QhByteArray;
	import pool.PoolManager;
	/**
	 * 网络信息的分发器
	 * @author gcxk721
	 */
	public class NetDistribute implements IMessageHandler 
	{
		
		private static var _instance : NetDistribute = new NetDistribute();
		
		public function NetDistribute() 
		{
			if (_instance != null)
			{
				throw new Error("NetDistribute is single instance!");
			}
		}
		
		/* INTERFACE net.IMessageHandler */
		public function onHandler(bytes:QhByteArray):void 
		{
			var mon : Mission = PoolManager.missionPool.getItem() as Mission;
			mon.serverId = bytes.readByte();
			mon.messageHead = bytes.readShort();
			mon.bytes = bytes;
			Application.sysLst[mon.serverId].handleMission(mon);
		}
		
		/**
		 * 取得NetDistribute的唯一实例
		 * @return NetDistribute
		 */
		public static function get instance() : NetDistribute
		{
			return _instance;
		}
		
	}

}